import {instance} from '@/api/shared'
import type {Resp} from "@/api/shared/type.ts";

export async function getReverseList(): Promise<Resp> {
    try {
        const res = await instance.get('/reversesh/config/all');
        return res.data;  // 直接返回 data
    } catch (err) {
        console.error(err);
        throw err;  // 可以选择重新抛出错误，或者返回默认值
    }
}

export async function addReverseConfig(data: any): Promise<Resp> {
    try {
        const res = await instance.post('/reversesh/config/add', data);
        return res.data;  // 直接返回 data
    } catch (err) {
        throw err;  // 可以选择重新抛出错误，或者返回默认值
    }
}

export async function enableReverseShPlugin(data: any): Promise<Resp> {
    try {
        const res = await instance.post('/reversesh/enable', data);
        return res.data;  // 直接返回 data
    } catch (err) {
        throw err;  // 可以选择重新抛出错误，或者返回默认值
    }
}

export interface ReverseShAuditData {
    id: number;
    cybertwin_id: number;
    syscall: string;
    node_name: string;
    event_time: string;
}

export async function getReverseShAuditResults(): Promise<Resp> {
    try {
        const res = await instance.get('/reversesh/audit/results');
        return res.data;
    } catch (err) {
        console.error(err);
        throw err;
    }
}
